Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

server-graceful-shutdown

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

server-graceful-shutdown

Graceful shutdown for node http(s) servers.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node http(s) server graceful shutdown

Adds a shutdown(callback) to nodes http(s) servers. shutdown() will stop accepting new connections and waits until all requests are finished. This is very similar to the node builtin close() function with the only difference that shutdown() destroys idle connections (e.g. keep alive connections) using a timeout (10 seconds as default) without data transfer.

Usage

var enableGracefulShutdown = require('server-graceful-shutdown');

var server = http.createServer(function(req, res) {
  // do stuff
});

server.listen(80);

// enhance server with a 'shutdown' function
enableGracefulShutdown(server);
// you can set the socket idle timeout using the second parameter 
// e.g. enableGracefulShutdown(server, 5000);

// some time later...
server.shutdown(function() {
	// all requests are finished 
	// we can 
	// process.exit() 
	// now
});

FAQs

Package last updated on 06 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc